package jmine.tec.database.query.columns;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Coluna do tipo String
 * 
 * @author lundberg
 */
public class StringColumn extends AbstractColumn {

    /**
     * Construtor
     * 
     * @param type type
     * @param name name
     */
    public StringColumn(int type, String name) {
        super(type, name);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String read(ResultSet rs) {
        try {
            return String.valueOf(rs.getString(this.getName()));
        } catch (SQLException e) {
            return super.read(rs);
        }
    }

    /**
     * {@inheritDoc}
     */
    public void setParameter(PreparedStatement st, int parameterIndex, String value) throws SQLException {
        st.setString(parameterIndex, value);
    }
}
